<template>
  <div class="car-wrap" :class="is_crossBorder? 'car-wrapCross': ''">
    <!-- 头部 -->
    <div class="car-top-bg">
      <div class="car-top">
        <i></i>
        <div class="addressInfo" @click="addressDialogVisible = true">
          <span>{{ addressInfo }}</span>
          <img src="https://img.wifenxiao.com/h5-wfx/images/item/shop-car/arrow.png" alt="">
        </div>
        <p v-show="lists.length > 0" v-if="!editStatus">
          <span @click="editStatus = !editStatus">编辑</span>
        </p>
        <p v-show="lists.length > 0" v-else>
          <span @click="editStatus = !editStatus">完成</span>
        </p>
      </div>
    </div>

    <address-dialog
      :visible.sync="addressDialogVisible"
      @selectAddress="selectAddress"></address-dialog>

    <a-map v-if="is_show_goods_address == 1" @getLatLng="onGetLatLng" />
    <self-address-dialog
      ref="selfAddressDialog"
      :shipType="selfAddressFormData.type"
      :buyLists="selfAddressFormData.buyLists"
      :latitude="selfAddressFormData.latitude"
      :longitude="selfAddressFormData.longitude"
      :itemId="selfAddressFormData.itemId"
      :fromShopCar="selfAddressFormData.fromShopCar"
      :visible.sync="selfAddressVisible"></self-address-dialog>

    <!-- 购物车列表 -->
    <div v-if="showCar && !is_crossBorder">
      <div class="car-middle">
        <div class="car-middle-wrap">
          <van-checkbox-group
            v-model="result"
            @change="handleChangeEvent"
            ref="checkboxGroup">
            <div
              v-for="(lists_vo, index) in lists"
              :key="index"
              class="checkbox-item letter-list"
              :class="is_dz_fq? 'roomItemBg':''">
              <div class="gys_info" v-if="lists_vo.is_duodian && lists_vo.new_supplier_id > 0">
                <!-- <van-checkbox
                  class="checkbox-item"
                  :name="lists_vo.cart_id||lists_vo.item_id"
                  icon-size="18px"
                  checked-color="#F42B2B">
                </van-checkbox> -->
                <img class="gys_logo" v-if="lists_vo.gys_logo" :src="lists_vo.gys_logo" alt />
                <span>{{lists_vo.gys_name}}</span>
                <img class="arrow" src="https://img.wifenxiao.com/h5-wfx/images/arrow_R.png" alt="">
              </div>
              <!--   广州加个番茄  仓库商品 定制 start      -->
              <div v-if="is_dz_fq" v-for="(lists_item, indexItem) in lists_vo.item_room_lists" :key="indexItem">
                <div>
                  <p v-if="is_dz_fq" class="is_dz_fq_title">{{lists_item[0].item_room_info.name}}</p>
                  <div  class="car_main room_dz" :class="[lists_item_room.give_item && lists_item_room.give_item.item_id ? 'gift' : '', is_show_goods_address == 1 ? 'pdbx100' : '']"  v-for="(lists_item_room, indexItemRoom) in lists_item" :key="indexItemRoom">
                    <van-checkbox
                            class="checkbox-item"
                            :name="lists_item_room.cart_id||lists_item.lists_item_room"
                            icon-size="18px"
                            checked-color="#F42B2B">
                    </van-checkbox>
                    <div class="car-middle-wrap-item">
                      <div class="car-goods">
                        <a @click="getGoodsDetailUrl(lists_item_room.item_id, lists_item_room.supplier_id )">
                          <div class="car-goods-img">
                            <img :src="lists_item_room.is_compress == 1 ?`${lists_item_room.pic_url}180x180`:lists_item_room.pic_url"
                                 alt />
                          </div>
                        </a>

                        <div class="car-goods-info">
                          <div class="title" @click="getGoodsDetailUrl(lists_item_room.item_id, lists_item_room.supplier_id)">
                            <div class="type">
                              <b v-if="lists_item_room.is_self_support"
                                 class="activity">自营</b>

                            </div>
                            {{lists_item_room.title}}
                          </div>
                          <div class="sku">
                            <p v-if="lists_item_room.item_date"
                               style="color: #999"
                               class="mgt5">日期：{{lists_item_room.item_date}}</p>
                            <p v-if="lists_item_room.item_memo"
                               style="color: #999">{{lists_item_room.item_memo}}</p>
                            <p v-if="lists_item_room.props">
                              <em>{{lists_item_room.props}}</em>
                            </p>
                            <p v-if="lists_item_room.package_label">
                              <i class="onePrice">{{lists_item_room.package_label}}</i>
                            </p>
                          </div>

                          <div class="activity-tips">
                            <b v-if="lists_item_room.is_miao"
                               class="activity">限时{{lists_item_room.actives_title}}</b>

                            <b v-else-if="lists_item_room.discount && lists_item_room.discount != '10' && !lists_item_room.package_org_price"
                               class="activity"
                               v-text="lists_item_room.is_limit_discount?lists_item_room.discount_sta==1?`限时会员 ¥${lists_item_room.discount}`:`限时会员${lists_item_room.discount}折`:`会员${lists_item_room.discount}折`"></b>

                            <b v-else-if="lists_item_room.is_bargin"
                               class="activity">砍价</b>
                            <b v-else-if="lists_item_room.is_bmd"
                               class="activity">多买优惠</b>
                            <!-- <p class="discounts"
                              style="display: none;">
                              省 &yen;
                              <b></b>
                            </p> -->
                          </div>

                          <div class="price clearfix">
                            <div>
                              <div class="price-now fl"
                                   v-html="scaleGoodsPriceFn(lists_item_room.price)"></div>
                              <!-- <span class="price-origin fl">{{mSymbol.name}}{{lists_item_room.original_price}}</span> -->
                            </div>

                            <div class="add fr">
                              <count-plug v-model="lists_item_room.num"
                                          :disabled="disabled"
                                          :itemId="lists_item_room.item_id"
                                          :key="lists_item_room.cart_id"
                                          :cartId="lists_item_room.cart_id"
                                          :skuId="String(lists_item_room.sku_id)"
                                          :maxLimit="lists_item_room.quota && lists_item_room.quota>0? Number(lists_item_room.quota) : Number(lists_item_room.item_num)"
                                          @changeShopCarNum="changeNum"></count-plug>
                            </div>
                          </div>
                          <div style="overflow:hidden">
                            <div class="tips">
                              <div class="purchase_nums" v-if="lists_item_room.restricted_purchase">{{lists_item_room.restricted_purchase}}</div>
                              <div class="purchase_nums" v-if="lists_item_room.saleNum" style="color: red">仅剩{{lists_item_room.saleNum}}{{lists_item_room.unit}}</div>
                            </div>
                          </div>
                          <!-- 定制番茄仓库 start -->
                          <p class="earnMoney" v-if="lists_item_room.pre_commission">
                            <span>可赚: </span><span>¥{{lists_item_room.pre_commission}}</span>
                          </p>
                          <!-- 定制番茄仓库 end -->
                          <!--赠品-->
                          <div class="gift" @click="JumpName('item-detail', lists_item_room.give_item.item_id)"
                               v-if="lists_item_room.give_item && lists_item_room.give_item.item_id">
                            <div class="gift-item">
                              <span class="icon_gift">赠品</span>
                              <span class="tit">{{ lists_item_room.give_item.title }}</span>
                              <span class="num">x{{ lists_item_room.give_item.num }}</span>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                    <div class="review-storeAddress" v-if="is_show_goods_address == 1" @click="showSelfAddressDialog(lists_item_room)">查看门店地址</div>

                  </div>
                </div>

              </div>

              <!--   广州加个番茄  仓库商品 定制 end      -->
              <div v-if="!is_dz_fq" class="car_main" :class="[lists_item.give_item && lists_item.give_item.item_id && Number(lists_item.give_item.num) > 0 ? 'gift' : '', is_show_goods_address == 1 ? 'pdbx100' : '']" v-for="(lists_item, indexItem) in lists_vo.content" :key="indexItem">
                <van-checkbox
                  class="checkbox-item"
                  :name="lists_item.cart_id||lists_item.item_id"
                  icon-size="18px"
                  checked-color="#F42B2B">
                </van-checkbox>
                <div class="car-middle-wrap-item">
                  <div class="car-goods">
                    <a @click="getGoodsDetailUrl(lists_item.item_id,lists_item.supplier_id)">
                      <div class="car-goods-img">
                        <img :src="lists_item.is_compress == 1 ?`${lists_item.pic_url}180x180`:lists_item.pic_url"
                            alt />
                      </div>
                    </a>

                    <div class="car-goods-info">
                      <div class="title" @click="getGoodsDetailUrl(lists_item.item_id,lists_item.supplier_id)">
                        <div class="type">
                          <b v-if="lists_item.is_self_support"
                            class="activity">自营</b>

                        </div>
                        {{lists_item.title}}
                      </div>
                      <div class="sku">
                        <p v-if="lists_item.item_date"
                          style="color: #999"
                          class="mgt5">日期：{{lists_item.item_date}}</p>
                        <p v-if="lists_item.item_memo"
                          style="color: #999">{{lists_item.item_memo}}</p>
                        <p v-if="lists_item.props">
                          <em>{{lists_item.props}}</em>
                        </p>
                        <p v-if="lists_item.package_label">
                          <i class="onePrice">{{lists_item.package_label}}</i>
                        </p>
                      </div>
                      <div class="activity-tips">
                        <b v-if="lists_item.is_miao" class="activity">限时{{lists_item.actives_title}}</b>

                        <b v-else-if="lists_item.discount && lists_item.discount != '10' && !lists_item.package_org_price"
                          class="activity"
                          v-text="lists_item.is_limit_discount?lists_item.discount_sta==1?`限时会员 ¥${lists_item.discount}`:`限时会员${lists_item.discount}折`:`会员${lists_item.discount}折`"></b>

                        <b v-else-if="lists_item.is_bargin"
                          class="activity">砍价</b>
                        <b v-else-if="lists_item.is_bmd"
                          class="activity">多买优惠</b>

                        <!-- <p class="discounts"
                          style="display: none;">
                          省 &yen;
                          <b></b>
                        </p> -->
                      </div>
                      <div class="price clearfix">
                        <div>
                          <div class="price-now fl"
                                v-html="scaleGoodsPriceFn(lists_item.price)"></div>
                          <!-- <span class="price-origin fl">{{mSymbol.name}}{{lists_item.original_price}}</span> -->
                        </div>

                        <div class="add fr">
                          <count-plug v-model="lists_item.num"
                                      :disabled="disabled"
                                      :itemId="lists_item.item_id"
                                      :key="lists_item.cart_id"
                                      :cartId="lists_item.cart_id"
                                      :skuId="String(lists_item.sku_id)"
                                      :maxLimit="lists_item.quota && lists_item.quota>0 ? Number(lists_item.quota) : Number(lists_item.item_num)"
                                      @changeShopCarNum="changeNum"></count-plug>
                        </div>
                      </div>
                      <div style="overflow:hidden">
                        <div class="tips">
                          <div class="purchase_nums" v-if="lists_item.restricted_purchase">{{lists_item.restricted_purchase}}</div>
                          <div class="purchase_nums" v-if="lists_item.saleNum" style="color: red">仅剩{{lists_item.saleNum}}{{lists_item.unit}}</div>
                        </div>
                      </div>
                      <!--赠品-->
                      <div class="gift" @click="JumpName('item-detail',{detailId: lists_item.give_item.item_id})"
                          v-if="lists_item.give_item && lists_item.give_item.item_id && Number(lists_item.give_item.num) > 0">
                        <div class="gift-item">
                          <span class="icon_gift">赠品</span>
                          <span class="tit">{{ lists_item.give_item.title }}</span>
                          <span class="num">x{{ lists_item.give_item.num }}</span>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="review-storeAddress" v-if="is_show_goods_address == 1" @click="showSelfAddressDialog(lists_item)">查看门店地址</div>
              </div>
            </div>
          </van-checkbox-group>
        </div>
        <div class="car-middle-wrap failed_goods_list"
             v-if='failed_lists && failed_lists.length!=0'>
          <section class="btn-qk">
            <p>失效商品{{clearInvalidItem == 1 ? invalidItemNum : failed_lists.length}}件</p>
            <a href="javascript:;"
               @click="handleClickDelFail(clearInvalidItem)"
               class="qkbtn">清空失效商品</a>
          </section>
          <van-checkbox-group v-model="failed_result"
                              disabled
                              ref="failed_goods_list">
            <van-checkbox :name="lists_vo.cart_id||lists_vo.item_id"
                          checked-color="#F42B2B"
                          class="letter-list letterpd"
                          v-for="(lists_vo, index) in failed_lists"
                          :key="index">
              <div class="car-middle-wrap-item">
                <div class="car-goods">
                  <a @click="getGoodsDetailUrl(lists_vo.item_id,lists_vo.supplier_id)">
                    <div class="car-goods-img">
                      <img :src="lists_vo.is_compress == 1 ?`${lists_vo.pic_url}180x180`:lists_vo.pic_url"
                           alt />
                    </div>
                  </a>

                  <div class="car-goods-info">
                    <a class="title" href="javascript:;">{{lists_vo.title}}</a>
                    <div class="sku">
                      <p>{{lists_vo.props}}</p>
                    </div>
                    <div class="price clearfix">
                      <div>
                        <div class="price-now fl"
                              v-html="scaleGoodsPriceFn(lists_vo.price)"></div>
                        <!-- <span class="price-origin fl">{{mSymbol.name}}{{lists_vo.original_price}}</span> -->
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </van-checkbox>
          </van-checkbox-group>
          <section class="detail_logo" v-if="surplusInvalidNum > 0">
            <span class="liner_detail"></span>
            <span class="detail_content">剩余{{surplusInvalidNum}}件失效商品</span>
            <span class="liner_detail"></span>
          </section>
        </div>
      </div>
      <!-- 底部按钮 -->
      <div class="car-bottom" v-if="lists.length > 0">
        <div class="car-package"
             :style="`bottom: ${navBarHeight}px`">
          <!-- 凑单弹窗 -->
          <div class="active-item">
            <add-on-item :checkedList="checkedList" ref="addOnItems" :subtractPrice="totalPrice" @refreshFn="refreshFn"></add-on-item>
          </div>
          <div class="car-package-num">
            <div class="car-checkbox">
              <van-checkbox
                v-model="checked"
                icon-size="18px"
                checked-color="#F42B2B"
                @click="checkAll">
                <span class="check-txt">全选</span>
              </van-checkbox>
            </div>
          </div>
          <div class="car-package-price" v-if="!editStatus">
            <div class="price">
              <div class="price-top">
                <p><span>合计: </span><span v-html="scaleGoodsPriceFn(totalPrice, 'package')"></span></p>
                <p class="price-top-yf"><span>不含运费</span></p>
              </div>
            </div>
            <div class="btn">
              <div  v-if="!is_dz_fq" class="btn-buy red-gra-btn" @click="handleClickSettlement">
                <span v-if="is_dhs_send==1">出货</span>
                <span v-else>去结算</span>
                (<i class="j-totalNum">{{totalNum}}</i>)
              </div>
              <div v-else class="btn-buy red-gra-btn" @click="handleClickSettlementDz">
                <span v-if="is_dhs_send==1">出货</span>
                <span v-else>去结算</span>
                (<i class="j-totalNum">{{totalNum}}</i>)
              </div>
            </div>
          </div>

          <div class="car-package-price delete-con" v-else>
            <div class="btn-delete danger-btn" @click="handleClickDelItem">
              <span>删除</span>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!--  跨境 定制 start  -->
    <cross-border v-show="is_crossBorder" :Lists="overseas_cart" @refreshPage="refreshFn" @crossPay="crossPay" :editStatusDZ="editStatus" :crossBorderObj="crossBorderObj"></cross-border>
    <!--  跨境 定制 end  -->
    <div v-if="isShowNoGood">
      <no-goods></no-goods>
    </div>
    <div v-if="dz_cart_img" @click="JumpMiniProgram()">
      <img :src="dz_cart_img" style="width: 100%" mode="widthFix">
    </div>
    <!-- 为你推荐 -->
    <div class="car_recommended" v-if="goodsRecommendation.type == 1 && goodsRecommendation.is_shopping_cart_recommend">
      <!-- 推荐商品 -->
      <goods-recommendation :goodsRecommendation="goodsRecommendation"></goods-recommendation>
    </div>
    <!-- 授权弹出框 -->
    <small-login ref="smalllogin"></small-login>
    <!-- 定制有个番茄仓库定制 弹窗 start -->

    <div class="dz_fq" v-if="is_dz_fq">
      <van-popup v-model="dz_fq_show">
        <div class="dz_fq_body">
          <p class="dz_fq_title">请分开结算以下商品</p>
          <div class="dz_fq_overflow">
            <ul>
              <van-radio-group v-model="dz_fq_checked">
                <li v-for="(item,index) in roomData" :key="index">
                  <div>
                    <van-radio :name="index" checked-color="#ee0a24" icon-size="22px">
                      <span class="dz_fq_">{{item.name}}</span>
                      <p class="dz_fq_goods">({{item.cartIds.length}}件商品)</p>
                    </van-radio>
                  </div>
                </li>
              </van-radio-group>
            </ul>
          </div>
          <div class="dz_fq_flex">
            <span class="dz_fq_backCar" @click="dz_fq_goBack">返回购物车</span>
            <span class="dz_fq_confirm" @click="dz_fq_confirm">确定</span>
          </div>
        </div>
      </van-popup>
    </div>

    <!-- 定制有个番茄仓库定制 弹窗 end -->
    <get-mobile :bindPhone="is_need_bind_phone" @close="closeMobile"></get-mobile>

  </div>
</template>

<script>
/**
 * @Author: yqe@360shop.cn
 * @Date: 2019-12-20 17:10:31
 * @Last Modified by: zhangmeng
 * @Last Modified time: 2020-09-08 15:49:28
 */
import Vue from 'vue'
import Store from '@/utils/store'
import { mapGetters } from 'vuex'
import { Checkbox, CheckboxGroup, Dialog } from 'vant'
import { isIOS } from '@/utils/validate'
Vue.use(Checkbox).use(CheckboxGroup).use(Dialog)
import noGoods from './components/noGoods/index'
import addOnItem from './components/addOnItem/index'
import CountPlug from '@/components/CountPlug'
import addressDialog from '@/components/addressDialog'
import getMobile from '@/views/item/components/skuDialog/getMobile.vue'
import { scaleGoodsPrice } from '@/utils/index.js'
import { getCartList, setCartItemNum, delCartItem, clearCartItem, checkCartStock } from '@/api/item/item.js'
import { openPage } from '@/utils/utils.js'
import SmallLogin from '@/components/SmallLogin/smallLogin'
import small from '@/smallapp/small.js'
import aMap from '@/views/shop/storeList/components/amap'
import selfAddressDialog from '@/views/order/buy/components/selfAddressDialog'
// 为你推荐
import goodsRecommendation from '../components/goodsRecommendation'
// 广州加个番茄定制
import { getstorehouseDz } from '@/api/dz/gzfqDzApi'
// 跨境 购物车组件
import crossBorder from './components/crossBorder/index'
export default Vue.extend({
  name: 'index',
  components: {
    CountPlug,
    noGoods,
    addOnItem,
    addressDialog,
    SmallLogin,
    aMap,
    selfAddressDialog,
    goodsRecommendation,
    crossBorder,
    getMobile
  },
  data() {
    return {
      navBarHeight: 0,
      addressInfo: '请选择收货地址',
      addressId: '',
      addressDialogVisible: false, // 地址弹层状态
      is_show_goods_address: 0, // 是否展示按钮查看商品所属门店
      latitude: '',
      longitude: '',
      selfAddressFormData: {
        latitude: '',
        longitude: '',
        type: '4',
        buyLists: [],
        itemId: '',
        fromShopCar: true
      },
      selfAddressVisible: false,
      editStatus: false, // 编辑状态
      checked: false, // 全选
      showCar: false, // 购物车有商品
      isShowNoGood: false,
      // 为你推荐
      goodsRecommendation: {},
      // 列表vant组件
      result: [], // 选中选项
      failed_result: [], // 失败商品
      clearInvalidItem: 0, // 当字段为1的时候下面两个参数启用
      invalidItemNum: 0, // 失效商品总数
      surplusInvalidNum: 0, // 剩余失效商品数量
      have_buy_again_item: 1, // 再买一次的商品
      disabled: true, // 步进器禁止点击
      is_dhs_send: 0,
      lists: [],
      failed_lists: [],
      package_cart_assign: [],
      checkedList: [], // 选中的商品
      dz_fq_show: false, // 定制番茄弹窗展示
      dz_fq_checked: [], // 定制番茄勾选框存储数据
      is_dz_fq: 0, // 定制番茄 仓库
      roomData: [], // 定制 番茄 仓库列表数据
      crossBorderObj: {},
      is_crossBorder: 0,
      overseas_cart: [],
      dz_isCrossBorderPrice: 0, // 定制跨境 是否显示 人民币
      dz_cart_img: '',
      dz_cart_appid: '',
      htmlData: '',
      is_need_bind_phone: false,
      is_dataset_json: 0 // dataset 是否以json格式提交
    }
  },
  created() {
    this.init()
    this.$Bus.$on('changeCartNum', () => {
      this.init()
    })
  },
  mounted() {
      if (!small.checkLogin()) {
        this.$refs.smalllogin.openSmallLoginPop()
      }
      window.$$subscribe('loginReload', reload => {
          if (reload) {
            this.init()
          }
      })
  },
  beforeDestroy() {
    window.$$unsubscribe('loginReload')
  },
  methods: {
    closeMobile() {
      this.is_need_bind_phone = false
    },
    JumpMiniProgram() {
      if (this.dz_cart_appid) {
        // 跳转小程序
        wx.navigateToMiniProgram({
          appId: this.dz_cart_appid,
          // path: 'pages/merchantAddress/merchantAddress',
          success(res) {
            // 打开成功
            // console.log(res)
          },
          fail(error) {
            wx.showModal({
              content: '跳转失败，请重试',
              showCancel: false,
              success: (res) => {}
            })
          }
        })	
      }
    },
    // 开启购物车查看门店地址后获取经纬度
    onGetLatLng(val) {
      this.latitude = val.lat
      this.longitude = val.lng
    },
    // 展示自提地址弹窗
    showSelfAddressDialog(item) {
      this.selfAddressFormData.latitude = this.latitude
      this.selfAddressFormData.longitude = this.longitude
      this.selfAddressFormData.buyLists = [item]
      this.selfAddressFormData.itemId = item.item_id
      this.selfAddressVisible = true
    },
    // 跳转
    JumpName(url, data) {
      this.$JumpName(this, url, data)
    },
    // 删除购物车商品
    handleClickDelItem() {
      Dialog.confirm({
        message: '确定删除?',
        className: 'common-confirm',
        closeOnClickOverlay: true
      }).then(() => {
        // on confirm
        const data = {}
        data.id = this.result
        delCartItem(data).then(res => {
          if (res.status == 1) {
            this.result = []
            this.init()
          }
        })
      }).catch(() => {
        // on cancel
      })
    },
    // 清空失效商品
    handleClickDelFail(type) {
      const failed_result = this.failed_result
      Dialog.confirm({
        message: '确定清空失效商品?',
        className: 'common-confirm',
        closeOnClickOverlay: true
      }).then(() => {
        // on confirm
        const data = {}
        data.id = failed_result
        if (type == 1) {
          clearCartItem().then(res => {
            if (res.status == 1) {
              this.$Error('清除成功')
              this.init()
            } else {
              this.$Error(res.msg)
            }
          })
        } else {
          delCartItem(data).then(res => {
            if (res.status == 1) {
              this.$Error('清除成功')
              this.init()
            } else {
              this.$Error(res.msg)
            }
          })
        }
      }).catch(() => {
        // on cancel
      })
    },
    /**
     * 结算
     */
    handleClickSettlement() {
      const checkbox = []
      const result = this.result // 选中的购物车ID
      const lists = this.lists // 所有的商品
      const idArr = []
      const numArr = []
      const dataset = []
      const activeArr = []
      // 判断当购物车没有选择商品的时候不允许提交结算
      if (result.length == 0) {
        this.$Error('请选择需要结算的商品')
        return false
      }
      // 开启门店服务奖商品列表
      const storeServeArr = []
      // 广州加个番茄 定制 仓库商品
      if (!this.is_dz_fq) {
        result.forEach((result, index) => {
          lists.forEach(list => {
            list.content.forEach(itemSub => {
              if (result == itemSub.cart_id) {
                const obj = {
                  dis: itemSub.dis,
                  checkbox: itemSub.cart_id,
                  is_need_subscribe: 0,
                  one_item_money: '',
                  limit_num: itemSub.limit_num,
                  json_ladder_price: '',
                  is_orderGoods: itemSub.is_orderGoods,
                  // is_mixedLot: 0,
                  num: itemSub.num,
                  sku_id: itemSub.sku_id
                }
                idArr.push(itemSub.item_id)
                numArr.push(itemSub.num)
                checkbox.push(itemSub.cart_id)
                dataset.push(obj)
                activeArr.push(itemSub.active) // 活动商品id
                itemSub.is_store_serve == 1 && storeServeArr.push(index)
              }
            })
          })
        })
      } else {
        result.forEach((result, index) => {
          lists.forEach(list => {
            for (const i in list.item_room_lists) {
              list.item_room_lists[i].forEach(itemSub => {
                if (result == itemSub.cart_id) {
                  const obj = {
                    dis: itemSub.dis,
                    checkbox: itemSub.cart_id,
                    is_need_subscribe: 0,
                    one_item_money: '',
                    limit_num: itemSub.limit_num,
                    json_ladder_price: '',
                    is_orderGoods: itemSub.is_orderGoods,
                    // is_mixedLot: 0,
                    num: itemSub.num,
                    sku_id: itemSub.sku_id
                  }
                  idArr.push(itemSub.item_id)
                  numArr.push(itemSub.num)
                  dataset.push(obj)
                  activeArr.push(itemSub.active) // 活动商品id
                  itemSub.is_store_serve == 1 && storeServeArr.push(index)
                }
              })
            }
          })
        })
      }

      if (storeServeArr.length && storeServeArr.length !== result.length) {
        this.$Error('参与门店服务的商品不能与其它商品下单')
        for (const store of storeServeArr) {
          this.result.splice(store, 1)
        }
        return
      }
      const orderBuy = {}
      orderBuy.dataset = dataset
      orderBuy.scanCode = ''
      orderBuy.addressId = this.addressId
      orderBuy.order_source = ''
      orderBuy.live_id = ''
      orderBuy.item_id = idArr.join(',')
      orderBuy.checkbox = ''
      orderBuy.num = numArr.join(',')
      orderBuy.assort_id = ''
      orderBuy.total_num = ''
      orderBuy.item_miao_id = ''
      orderBuy.item_limit_discount_id = ''
      orderBuy.item_bargin_id = ''
      orderBuy.item_cycle_buy_id = ''
      orderBuy.active = activeArr.join(',')
      orderBuy.type = 'oncart'
      if (this.is_dataset_json) {
        orderBuy.dataset = JSON.stringify(orderBuy.dataset)
      }
      // console.log(orderBuy, '结算数据')
      Store.save('orderBuy', orderBuy)
      this.$loadingWrap.show()
      checkCartStock({
        ...orderBuy,
        type: '',
        checkbox: checkbox.join(',')
      }).then(res => {
        this.$loadingWrap.close()
        if (res.status == 1) {
          if (res.data.cart_list.length > 0) {
            const roomData = res.data.cart_list
            const data = this.lists
            let errorMsg = ''
            data.forEach(j => {
              for (const i in j.content) {
                j.content[i].saleNum = ''
              }
            })
            roomData.forEach(list => {
              data.forEach(j => {
                for (const i in j.content) {
                  // console.log('list', list.cart_id, j.content[i].cart_id )
                  if (j.content[i].cart_id == list.cart_id) {
                    j.content[i].saleNum = list.stock_num
                    errorMsg += `商品:${j.content[i].title}库存仅剩${list.stock_num}${j.content[i].unit};`
                  }
                }
              })
              this.lists = []
              this.lists = data
            })
            this.$Error(errorMsg, 5000)
          } else {
            if (this.htmlData.is_need_bind_phone) {
              this.is_need_bind_phone = true
              return false
            }
            this.$JumpName(this, 'buy')
          }
        }
      })

    },
    // 广州加个番茄 定制 结算
    handleClickSettlementDz() {
      const result = this.result // 选中的购物车ID
      const lists = this.lists // 所有的商品
      const idArr = []
      const cartIds = []
      const sendData = []
      this.roomData = []
      // 判断当购物车没有选择商品的时候不允许提交结算
      if (result.length == 0) {
        this.$Error('请选择需要结算的商品')
        return false
      }
      result.forEach((result, index) => {
        lists.forEach(list => {
          for (const i in list.item_room_lists) {
            list.item_room_lists[i].forEach(itemSub => {
              if (result == itemSub.cart_id) {
                const obj = {
                  item_id: itemSub.item_id,
                  cart_id: itemSub.cart_id
                }
                idArr.push(itemSub.item_id)
                cartIds.push(itemSub.cart_id)
                sendData.push(obj)
              }
            })
          }
        })
      })
      this.dz_fq_show = !this.dz_fq_show // 番茄定制 弹窗控制
      getstorehouseDz({ cart_item_arr: sendData }).then(res => {
        if (res.status) {
          const resData = res.data
          for (const i in resData) {
            const obj = {
              id: resData[i][0].id,
              name: resData[i][0].name,
              item_ids: resData[i][0].item_ids,
              cartIds: []
            }
            resData[i].forEach((item) => {
              obj.cartIds.push(item.cart_id)
            })
            this.roomData.push(obj)
          }
        }
      })
    },
    /**
     * 地址弹层抛出的地址信息
     */
    selectAddress(val) {
      this.addressInfo = val.province + val.city + val.area + val.town + val.address
      this.addressId = val.address_id
    },
    /**
     * 凑单弹窗加入购物车之后刷新购物车数据
     */
    refreshFn() {
      this.init()
    },
    init() {
      this.$loadingWrap.show()
      setTimeout(() => {
        this.$loadingWrap.close()
      }, 10000)
      const data = {}
      getCartList(data)
        .then(res => {
          this.$loadingWrap.close()
          if (res.status == 1) {
            const resData = res.data
            this.htmlData = resData
            this.is_show_goods_address = resData.is_show_goods_address
            this.lists = resData.lists
            this.failed_lists = resData.failed_lists
            this.package_cart_assign = resData.package_cart_assign
            this.clearInvalidItem = resData.clear_invalid_item // 当失效商品大于100的时候变为1
            this.invalidItemNum = resData.invalid_item_num // 失效商品总数 当clearInvalidItem为1的时候启用
            this.surplusInvalidNum = resData.surplus_invalid_num // 剩余失效商品总数 当clearInvalidItem为1的时候启用
            this.dz_cart_img = resData.dz_cart_img || ''
            this.dz_cart_appid = resData.dz_cart_appid || ''
            this.is_dataset_json = resData.is_dataset_json || 0
            // 为你推荐
            const itemIdArr = []
            this.lists.forEach(list => {
              list.content.forEach(itemSub => {
                itemIdArr.push(itemSub.item_id)
              })
            })
            // 商品仓库 定制 start
            if (resData.is_item_room_dz) {
              this.is_dz_fq = resData.is_item_room_dz
              // this.is_dz_fq = 0
            }
            // 商品仓库 定制 end
            // 跨境 定制
            if (resData.is_open_kuajing) {
              this.dz_isCrossBorderPrice = resData.is_use_price_symbol || 0
              this.is_crossBorder = resData.is_open_kuajing || 0
              this.overseas_cart = resData.overseas_cart || []
              if (this.overseas_cart.length == 0) {
                this.isShowNoGood = true
              } else {
                this.isShowNoGood = false
              }
              Store.saveLocal('isCrossBorder', this.dz_isCrossBorderPrice)
              Store.saveLocal('is_open_kuajing', this.is_crossBorder)
              if (this.dz_isCrossBorderPrice) {
                this.$store.dispatch('setMoneySymbol')
              }
            }
            this.crossBorderObj = {
              failed_lists: this.failed_lists,
              clearInvalidItem: this.clearInvalidItem,
              invalidItemNum: this.invalidItemNum,
              surplusInvalidNum: this.surplusInvalidNum,
              package_cart_assign: this.package_cart_assign,
              is_show_goods_address: this.is_show_goods_address,
              dz_isCrossBorderPrice: this.dz_isCrossBorderPrice
            }
            this.goodsRecommendation.classId = resData.class_ids || ''
            this.goodsRecommendation.goods_recommend_names = '为你推荐'
            this.goodsRecommendation.type = 1
            this.goodsRecommendation.itemIds = itemIdArr
            this.goodsRecommendation.is_shopping_cart_recommend = resData.is_shopping_cart_recommend
            if (resData.lists.length > 0 || resData.failed_lists.length > 0) {
              this.showCar = true
              this.isShowNoGood = false
              // $('#navbar').hide()
              // TODO 原生js替换jq
              document.querySelector('#navbar').style.display = 'none'
            } else {
              this.isShowNoGood = true
              this.showCar = false
              // $('#navbar').show()
              document.querySelector('#navbar').style.display = 'block'
            }
            this.createdResultData()
            this.createdFailedResultData()
            this.handleTiredPrice()
          } else {
            this.$Error(res.msg)
          }
        })
        .catch(() => {
          this.error = true
        })
    },
    createdResultData() {
      const newResult = []
      this.lists.map(val => {
        val.content.forEach(itemSub => {
          newResult.push(itemSub.cart_id)
          this.result = newResult
          if ((this.have_buy_again_item && itemSub.buy_again_check && !itemSub.is_pack_item) || (!this.have_buy_again_item && !itemSub.is_pack_item)) {
            // console.log('默认选中')
          }
        })
      })
    },
    createdFailedResultData() {
      this.failed_lists.map(val => {
        this.failed_result.push(val.cart_id)
      })
    },
    scaleGoodsPriceFn(price) {
      return scaleGoodsPrice(price, 'large')
    },
    // TODO 小程序跳转方式修改
    getGoodsDetailUrl(item_id, supplier_id) {
        let url = '/item-detail?detailId=' + item_id
        if (supplier_id) {
          url += '&supplierId=' + supplier_id
        }
        window.open(url)
    },
    // 全选
    checkAll() {
      if (this.checked) {
        const arr = []
        const lists = this.lists
        lists.forEach(item => {
          item.content.forEach(itemSub => {
            arr.push(itemSub.cart_id)
          })
        })
        this.result = arr
      } else {
        this.result = []
      }
      this.handleTiredPrice(this.handleTotalNum())
      // this.$refs.checkboxGroup.toggleAll(this.checked)
      this.$refs.addOnItems.init() // 验证是否满足满减条件
    },
    // 单个商品选择
    handleChangeEvent() {
      this.handleTiredPrice(this.handleTotalNum())
      this.$refs.addOnItems.init() // 验证是否满足满减条件
    },
    // 处理订货商阶梯价
    handleTiredPrice(tNum, num) {
      const lists = this.lists
      const result = this.result
      for (let i = 0; i < lists.length; i += 1) {
        for (let j = 0; j < this.lists[i].content.length; j++) {
          if (this.lists[i].content[j].json_ladder_price && JSON.parse(this.lists[i].content[j].json_ladder_price).length > 0) {
            // if (result.includes(this.lists[i].content[j].cart_id)) {
            //   this.lists[i].content[j].price = this.handleCommon(this.lists[i].content[j], tNum)
            // } else {
              this.lists[i].content[j].price = this.handleCommon(this.lists[i].content[j], num)
            // }
          }
        }
      }
    },
    handleCommon(content, num) {
      const jsonLadderPrice = JSON.parse(content.json_ladder_price)
      const newPrice = content.before_price ? content.before_price : content.price
      const tNum = num || content.num / 1
      if (tNum <= jsonLadderPrice[jsonLadderPrice.length - 1].ladder_max) {
        for (let k = 0; k < jsonLadderPrice.length; k++) {
          if (tNum <= jsonLadderPrice[k].ladder_max && tNum >= jsonLadderPrice[k].ladder_min) {
            return jsonLadderPrice[k].ladder_region_price
          }
        }
      }
      return newPrice
    },
    handleTotalNum() {
      const lists = this.lists
      const result = this.result
      let num = 0
      const numArr = []
      // 广州加个番茄 定制
      if (!this.is_dz_fq) {
        lists.forEach(item => {
          item.content.forEach(itemSub => {
            result.forEach(it => {
              if (it == itemSub.cart_id) {
                numArr.push(parseInt(itemSub.num))
              }
            })
          })
        })
      } else {
        lists.forEach(item => {
          for (const i in item.item_room_lists) {
            item.item_room_lists[i].forEach(itemSub => {
              result.forEach(it => {
                if (it == itemSub.cart_id) {
                  numArr.push(parseInt(itemSub.num))
                }
              })
            })
          }
        })
      }

      numArr.forEach((val, index, arr) => {
        num += val
      })
      return num
    },
    // 加减数量
    changeNum(agr) {
      const lists = this.lists
      const result = this.result
      let tNum = this.handleTotalNum()
      if (agr[1] === 'add') {
        tNum += 1
      } else if (agr[1] === 'reduce') {
        tNum -= 1
      }
      // 开始处理订货商阶梯价
      //  广州加个 番茄 定制
      if (this.is_dz_fq) {
        for (let i = 0; i < lists.length; i += 1) {
          for (const z in this.lists[i].item_room_lists) {
            for (let j = 0; j < this.lists[i].item_room_lists[z].length; j++) {
              if (JSON.parse(this.lists[i].item_room_lists[z][j].json_ladder_price).length > 0) {
                // if (result.includes(this.lists[i].item_room_lists[z][j].cart_id)) {
                //   this.lists[i].item_room_lists[z][j].price = this.handleCommon(this.lists[i].item_room_lists[z][j], tNum)
                // } else {
                  if (agr[4] && this.lists[i].item_room_lists[z][j].cart_id == agr[4]) {
                    this.lists[i].item_room_lists[z][j].price = this.handleCommon(this.lists[i].item_room_lists[z][j], agr[0])
                  }
                // }
              }
            }
          }
        }
      } else {
        for (let i = 0; i < lists.length; i += 1) {
          for (let j = 0; j < this.lists[i].content.length; j++) {
            if (this.lists[i].content[j].json_ladder_price && JSON.parse(this.lists[i].content[j].json_ladder_price).length > 0) {
              // if (result.includes(this.lists[i].content[j].cart_id)) {
              //   this.lists[i].content[j].price = this.handleCommon(this.lists[i].content[j], tNum)
              // } 
              if (agr[4] && this.lists[i].content[j].cart_id == agr[4]) {
                this.lists[i].content[j].price = this.handleCommon(this.lists[i].content[j], agr[0])
              }
            }
            // 买赠 赠品，buy_more_and_send_more：多买多赠开关，need_buy_num：购买数量，buy_gift_num：赠送数量
            if (this.lists[i].content[j].item_id == agr[2]) {
              if (this.lists[i].content[j].give_item.item_id) {
                if (this.lists[i].content[j].give_item.buy_more_and_send_more) {
                  // 开启多买多赠，需要购买数量大于等于need_buy_num，赠送数量为每达到need_buy_num赠送buy_gift_num
                  if (agr[0] >= this.lists[i].content[j].give_item.need_buy_num) {
                    this.lists[i].content[j].give_item.num = Math.floor(agr[0] / this.lists[i].content[j].give_item.need_buy_num) * this.lists[i].content[j].give_item.buy_gift_num
                  } else {
                    this.lists[i].content[j].give_item.num = 0
                  }
                } else {
                  if (agr[0] >= this.lists[i].content[j].give_item.need_buy_num) {
                    this.lists[i].content[j].give_item.num = this.lists[i].content[j].give_item.buy_gift_num
                  } else {
                    this.lists[i].content[j].give_item.num = 0
                  }
                }
              }
            }
          }
        }
      }
      const params = {
        num: agr[0],
        item_id: agr[2],
        sku_id: agr[3]
      }
      setCartItemNum(params).then(res => {
        if (res.status == 1) {
          // console.log(res)
        } else {
          this.$Error(res.msg)
        }
      })
      this.$refs.addOnItems.init() // 验证是否满足满减条件
    },
    // price字体大小
    fontprize(obj) {
      $(obj).each(() => {
        var me = $(this)
        var nprice = me.find('.nums').text()
        var numarr = nprice.split('.')
        me.find('.integer').text(numarr[0] + '.')
        me.find('.decimal').text(nprice.indexOf('.') == -1 ? '00' : numarr[1])
        me.find('.nums').hide()
      })
    },
    // 定制番茄仓库 start
    dz_fq_goBack() {
      this.dz_fq_show = false
      this.dz_fq_checked = []
    },
    dz_fq_confirm() {
      this.dz_fq_show = false
      this.result = this.roomData[this.dz_fq_checked].cartIds
      this.handleClickSettlement()
    },
    // 定制番茄仓库 end
    crossPay(item) {
      const idArr = []
      const numArr = []
      const dataset = []
      const activeArr = []
      // 开启门店服务奖商品列表
      const storeServeArr = []
      item.checkResult.forEach((result, index) => {
        item.list.forEach((goods) => {
          if (result == goods.cart_id || result == goods.item_id) {
            const obj = {
              dis: goods.dis,
              checkbox: goods.cart_id,
              is_need_subscribe: 0,
              one_item_money: '',
              limit_num: goods.limit_num,
              json_ladder_price: '',
              is_orderGoods: goods.is_orderGoods,
              // is_mixedLot: 0,
              num: goods.num,
              sku_id: goods.sku_id
            }
            idArr.push(goods.item_id)
            numArr.push(goods.num)
            dataset.push(obj)
            activeArr.push(goods.active)
            goods.is_store_serve == 1 && storeServeArr.push(index)
          }
        })
      })
      const orderBuy = {}
      orderBuy.dataset = dataset
      orderBuy.scanCode = ''
      orderBuy.addressId = this.addressId
      orderBuy.order_source = ''
      orderBuy.live_id = ''
      orderBuy.item_id = idArr.join(',')
      orderBuy.checkbox = ''
      orderBuy.num = numArr.join(',')
      orderBuy.assort_id = ''
      orderBuy.total_num = ''
      orderBuy.item_miao_id = ''
      orderBuy.item_limit_discount_id = ''
      orderBuy.item_bargin_id = ''
      orderBuy.item_cycle_buy_id = ''
      orderBuy.active = activeArr.join(',')
      orderBuy.type = 'oncart'
      Store.save('orderBuy', orderBuy)
      this.$JumpName(this, 'buy')
    }
  },
  computed: {
    ...mapGetters(['navStyle', 'mSymbol']), // 0为纯文字导航
    totalPrice() { // 计算总价
      const lists = this.lists
      const result = this.result
      let sum = 0
      const sumArr = []
      // 广州加个番茄 定制
      if (!this.is_dz_fq) {
        lists.forEach(item => {
          item.content.forEach(itemSub => {
            result.forEach(it => {
              if (it == itemSub.cart_id) {
                sumArr.push(parseFloat(itemSub.price * 1000) * parseInt(itemSub.num))
              }
            })
          })
        })
      } else {
        lists.forEach(item => {
          for (const i in item.item_room_lists) {
            item.item_room_lists[i].forEach(itemSub => {
              result.forEach(it => {
                if (it == itemSub.cart_id) {
                  sumArr.push(parseFloat(itemSub.price * 1000) * parseInt(itemSub.num))
                }
              })
            })
          }
        })
      }
      sumArr.forEach((val, index, arr) => {
        sum += val
      })
      sum = (sum / 1000).toFixed(2)
      return sum
    },
    totalNum() {
      const lists = this.lists
      const result = this.result
      let num = 0
      const numArr = []
      // 广州加个番茄 定制
      if (!this.is_dz_fq) {
        lists.forEach(item => {
          item.content.forEach(itemSub => {
            result.forEach(it => {
              if (it == itemSub.cart_id) {
                numArr.push(parseInt(itemSub.num))
              }
            })
          })
        })
      } else {
        lists.forEach(item => {
          for (const i in item.item_room_lists) {
            item.item_room_lists[i].forEach(itemSub => {
              result.forEach(it => {
                if (it == itemSub.cart_id) {
                  numArr.push(parseInt(itemSub.num))
                }
              })
            })
          }
        })
      }
      numArr.forEach((val, index, arr) => {
        num += val
      })
      return num
    }
  },
  watch: {
    result(val) {
      const lists = this.lists
      const checkedList = []
      val.forEach(item => {
        lists.forEach(list => {
          if (this.result.length < list.content.length) {
            this.checked = false
          } else {
            this.checked = true
          }
          list.content.forEach(itemSub => {
            if (itemSub.cart_id == item) {
              checkedList.push(itemSub)
            }
          })
        })
      })
      this.checkedList = checkedList
    }
  }
})
</script>
<style lang="scss">
@import "src/styles/mixin";
@import "src/styles/variables";
.car-wrapCross{
  padding-bottom: 50px !important;
}
.miniprogram-root {
  .van-popup__close-icon{
    font-size: 44rpx;
  }
}
.car-wrap {
  padding-bottom: 110px;
  .car-top-bg{
    background: #f7f7f7;
  }
  .car-top {
    display: flex;
    background: #fff;
    border-radius: 0 0 20px 20px;
    height: 96px;
    padding: 0 25px;
    justify-content: space-between;
    align-items: center;
    i {
      display: block;
      width: 24px;
      height: 30px;
      background: url("https://img.wifenxiao.com/h5-wfx/images/item/shop-car/weizhi.png")
        center/cover no-repeat;
    }
    div.addressInfo {
      display: flex;
      align-items: center;
      flex: 1;
      font-size: 28px;
      color: #999999;
      padding: 0 50px 0 20px;
      @include showEllipsis;
      img{
        width: 9px;
        height: 16px;
        margin-left: 10px;
      }
    }
    p {
      font-size: 28px;
      color: #333333;
    }
  }
  .car-middle {
    &-wrap {
      margin: 20px 24px 0;
      .letter-list {
        padding: 30px 0 0;
        margin-bottom: 20px;
        background: #fff;
        border-radius: 20px;
        .gys_info{
          display: flex;
          display: -webkit-flex;
          display: -moz-flex;
          display: -ms-flexbox;
          align-items: center;
          padding-left: 88px;
          .gys_logo{
            width: 32px;
            height: 32px;
            margin-right: 16px;
          }
          span{
            display: inline-block;
            max-width: 220px;
            font-weight: bold;
            font-size: 28px;
            @include showEllipsis
          }
          .arrow{
            width: 16px;
            height: 16px;
            margin-left: 16px;
          }
        }
        .car_main{
          display: flex;
          display: -webkit-flex;
          display: -moz-flex;
          display: -ms-flexbox;
          align-items: center;
          padding: 30px 20px;
          border-bottom: 1px solid #eee;
          position: relative;
          &.gift{
            padding: 30px 20px 84px;
          }
          &:first-child{
            padding-top: 0;
          }
          &:last-child{
            border-bottom: none;
          }
          &.pdbx100 {
            padding-bottom: 100px;
          }
          .review-storeAddress {
            position: absolute;
            right: 20px;
            bottom: 24px;
            color: #fff;
            background: #F42B2B;
            padding: 12px 26px;
            border-radius: 50px;
          }
        }
        &.letterpd{
          padding-left: 20px;
          padding-bottom: 30px;
        }
        .checkbox-item{
          flex: 0 40px;
          justify-content: center;
          margin-right: 30px;
        }
        &:last-child {
          margin-bottom: 0;
        }
      }
      &-item {
        position: relative;
        display: flex;
        flex-direction: row;
        flex: 1;
        .car-checkbox {
          margin-right: 20px;
          margin-top: 60px;
        }
        .car-goods {
          flex: 1;
          display: flex;
          flex-direction: row;
          &-img {
            width: 180px;
            height: 180px;
            overflow: hidden;
            border-radius: 10px;
            img {
              width: 100%;
              height: 100%;
            }
          }
          &-info {
            margin-left: 14px;
            flex: 1;
            position: relative;
            .title {
              @include lineClamp(28px,36px,2);
              color: #333;
              // padding-bottom: 10px;
              height: 72px;
              overflow: hidden;
              .type {
                display: inline-block;
                b {
                  display: inline-flex;
                  font-size: 22px;
                  color: #fff;
                  line-height: 24px;
                  padding: 4px 8px;
                  margin-right: 4px;
                  background: $warning;
                  border-radius: 15px;
                }
              }
            }
            .sku {
              padding: 0 4px;
              font-size: 24px;
              color: #9a9a9a;
              line-height: 1;
              margin-bottom: 10px;
              .onePrice{
                display: inline-block;
                color: #fff;
                padding: 2px 4px;
                margin-top: -5px;
                font-size: 24px;
                border-radius: 6px;
                line-height: 24px;
                /*background: -moz-linear-gradient(right,#FCB700,#FC4D00);*/
                @include gradient(right, #FFAD00, #FF8901);
              }
            }
            //活动标签
            .activity-tips{
              .activity {
                display: inline-flex;
                font-size: 22px;
                line-height: 24px;
                padding: 4px 8px;
                margin-right: 10px;
                margin-bottom: 12px;
                border-radius: 24px;
                @include btnGroup($fontDefault, $bgDefault);
              }
            }
            .price {
              // position: absolute;
              // left: 0;
              // bottom: 0;
              width: 100%;
              line-height: 40px;
              &-scale {
                font-size: 24px;
                color: #f42b2b;
              }
              &-origin {
                font-size: 24px;
                color: #999;
                text-decoration: line-through;
                margin-left: 10px;
              }
              .add {
                // flex: 1;
                // position: absolute;
                // right: 20px;
                // bottom: 10px;
                // width: 250px;
              }
            }
            .gift{
              position: absolute;
              left: 0;
              bottom: -54px;
              width: 100%;
              &-item{
                display: flex;
                align-items: center;
                .icon_gift{
                  display: inline-block;
                  font-size: 18px;
                  color: #fff;
                  width: 62px;
                  height: 34px;
                  line-height: 34px;
                  text-align: center;
                  background-color: #ff4d4f;
                  border-radius: 6px;
                  margin-right: 12px;
                }
                .tit, .num{
                  display: inline-block;
                }
                .tit{
                  width: 276px;
                  margin-right: 30px;
                  line-height: 36px;
                  @include showEllipsis;
                }
              }
            }
          }
        }
      }
      &.failed_goods_list {
        // opacity: 0.5;
        background: #fff;
        border-radius: 20px;
        .btn-qk {
          overflow: hidden;
          padding: 30px;
          p {
            float: left;
            font-size: 28px;
            color: #333333;
          }
          .qkbtn {
            float: right;
            font-size: 28px;
            color: #666666;
            padding-left: 35px;
            background-image: url("https://img.wifenxiao.com/h5-wfx/images/item/shop-car/delete.png");
            background-size: 30px 32px;
            background-position: left center;
            background-repeat: no-repeat;
          }
        }
        .title {
          color: #999;
        }
        .price-scale {
          font-size: 24px;
          color: #999;
        }
        .detail_logo{
          font-size: 28px;
          text-align: center;
          padding: 0 0 30px;
          display: flex;
          justify-content: center;
          align-items: center;
          .detail_content{
            padding:0 10px;
            color: #999;
          }
          .liner_detail{
            height: 1px;
            width: 100px;
            background: #ccc;
            margin-top: 4px;
          }
        }
      }
    }
  }
  .car-bottom {
    position: relative;
    .active-item{
      position: absolute;
      width: 100%;
      top: -80px;
    }
    .car-package {
      width: 100%;
      position: fixed;
      bottom: 100px;
      left: 0;
      background: #fff;
      padding: 11px 0;
      border-top: 1px solid #ddd;
      display: flex;
      flex-direction: row;
      z-index: 1111;
      padding-bottom: constant(safe-area-inset-bottom); /*兼容 IOS<11.2*/
      padding-bottom: env(safe-area-inset-bottom); /*兼容 IOS>11.2*/
      &.style2 {
        bottom: 100px;
      }
      .check-txt {
        color: #333333;
        font-size: 28px;
      }
      &-num {
        padding-left: 44px;
        padding-top: 10px;
        span {
          line-height: 60px;
        }
        .count {
          @include alignTop;
        }
      }
      &-price {
        flex: 1;
        display: flex;
        flex-direction: row;
        position: relative;
        &.delete-con{
          height: 77px;
        }
        .price {
          flex: 1;
          // text-align: right;
          padding-left: 37px;
          &-top {
            padding-top:4px;
            // color: $warning;
            font-size: 24px;
            line-height: 36px;
            text-align: right;
            &-yf {
              font-size: 22px;
              color: #999;
              text-align: left;
              span{
                margin-left: 64%;
              }
            }
          }
        }
        .btn {
          margin-right: 25px;
          margin-left: 50px;
          &-buy {
            font-weight: bold;
            font-size: 28px;
            color: #fff;
            width: 208px;
            line-height: 76px;
            text-align: center;
            border-radius: 38px;
            margin-top: 2px;
            .j-totalNum{
              font-weight: bold;
            }
          }
          &-delete {
            width: 136px;
            height: 60px;
            font-size: 26px;
            color: $warning;
            border: 2px solid $warning;
            background: #fff;
            text-align: center;
            border-radius: 30px;
            line-height: 60px;
            float: right;
            margin-top: 6px;
            position: absolute;
            right: 20px;
          }
        }
      }
    }
  }
}
</style>
<style lang="scss">
.car-wrap {
  .letter-list {
    &:last-child {
      .car-middle-wrap-item {
        border: none;
      }
    }
  }
  .car-middle-wrap {
    .price-origin {
      height: 44px;
      line-height: 50px;
    }
  }
  .failed_goods_list {
    .price-scale {
      color: #999;
    }
    .van-checkbox__icon{
      height: 40px;
      line-height: initial;
    }
    .van-checkbox__icon--disabled .van-icon {
      border: 0;
      width: 62px;
      height: 36px;
      background: #d9d9d9;
      border-radius: 18px;
      &::before {
        content: "失效";
        color: #fff;
        font-size: 24px;
        line-height: 30px;
        display: block;
      }
    }
  }
}
.price-top{
  .price-scale {
    color: #F21228;
    font-size: 26px;
    /*font-weight:bold;*/
    &.large .num-font{
      font-size: 32px !important;
    }
  }
}

.price-scale {
    color: #F21228;
    font-size: 26px;
    &.large .num-font{
      font-size: 32px !important;
    }
  }
.car-middle-wrap{
  .van-checkbox__icon {
    /*margin: 0 0 0 10px;*/
  }
}
.van-checkbox__label {
  flex: 1;
}
.self-address-dailog {
  .self-address-title, .self-address-choose {
    line-height: 90px;
  }
}
// 定制 番茄仓库 start
.dz_fq_body{
  width: 558px;
  height: 524px;
  opacity: 1;
  background: #ffffff;
  border-radius: 116x;
  text-align: center;
}
.dz_fq_title{
  font-size: 32px;
  font-family: PingFangSC, PingFangSC-Regular;
  font-weight: 600;
  color: #333333;
  line-height: 44px;
  margin-top: 24px;
}
.van-popup--center{
  border-radius: 16px !important;
}
.dz_fq_flex{
  width: 90%;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;

}
.dz_fq_backCar{
  width: 228px;
  line-height: 60px;
  opacity: 1;
  border: 2px solid #DCDCDC;
  border-radius: 38px;
}
.dz_fq_confirm{
  width: 228px;
  opacity: 1;
  background: linear-gradient(270deg,#e90104, #fe1b49 100%, #fe1b49);
  border-radius: 38px;
  color: white;
  line-height: 60px;

}
.dz_fq_overflow{
  ul {
    margin: 20px 0;
    li{
      width: 90%;
      margin: 4px auto;
      font-size: 30px;
      line-height: 40px;
      margin-left: 30px;
      font-family: PingFangSC, PingFangSC-Regular;
      margin-bottom: 30px;
      div{
        margin-left: 10px;
        span{
          margin-left: 10px;
          color: black;
          opacity: 1;
          font-size: 24px;
          font-weight: 500;
          text-align: left;
          color: black;
          line-height: 26px;
          letter-spacing: 1px;
        }
        .dz_fq_goods{
          margin-left: 10px;
          color: #C5C5C5;
          opacity: 1;
          font-size: 20px;
          font-weight: 400;
          text-align: left;
          color: #999999;
          line-height: 26px;
          letter-spacing: 1px;
        }
      }

    }

  }}

.dz_fq_overflow{
  overflow-y: scroll;
  height: 400px;
}
.earnMoney{
  color: #F42B2B;
}
.is_dz_fq_title{
  line-height: 80px;
  font-size: 28px;
  font-weight: 500;
}
.roomItemBg{
  background-color: transparent !important;
  border-radius: 0 !important;
  padding-top: 0 !important;
  /*padding: 30px 0 0;*/
  /*margin-bottom: 20px;*/
  /*background: #fff;*/
  /*border-radius: 20px;*/
}
.room_dz{
  background: #fff;
  border-radius: 20px;
}
.tips {
  overflow: hidden;
  float: right;
  width: 180px;
  .purchase_nums {
    font-size: 20px;
    color: #666666;
    padding-top: 10px;
    text-align: center;
  }
}

</style>
